/*
 * ImagePanel.java
 *
 * Created on April 19, 2007, 6:15 PM
 */

package org.voidness.twittava.gui;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.awt.image.FilteredImageSource;
import java.awt.image.ImageFilter;
import java.awt.image.ImageProducer;
import java.awt.image.ReplicateScaleFilter;
import org.voidness.twittava.remoteimages.ImageRetriever;
import org.voidness.twittava.remoteimages.RemoteImageListener;

/**
 *
 * @author  void
 */
public class ImagePanel extends javax.swing.JPanel {
    
    private Image image = null;
    
    /** Creates new form ImagePanel */
    public ImagePanel() {
        initComponents();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 49, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 38, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
    
    public void paint(Graphics graphics) {
        // Parent paints first
        super.paint(graphics);
        
        if (image != null) {
            // Draw the image resized
            graphics.drawImage(image, 0, 0, this.getSize().width, this.getSize().height, this);
        }
    }
    
    public void setImage(Image image) {
        this.image = image;
        this.repaint();
    }
    
    public Image getImage() {
        return this.image;
    }
    
}
